<template>
  <div class="app-container">
    <!-- 查询 -->
    <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" v-if="isHeaderDisplay" :isDisplayDefaultSearch="false">
      <template slot="search">
        <el-form-item label="申请人">
          <el-input v-model="queryParam.qry_user" placeholder="工号或姓名" width="180px"></el-input>
        </el-form-item>
        <el-form-item label="单据编号">
          <el-input v-model="queryParam.qry_docno" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="单据日期">
          <el-date-picker v-model="queryParam.qry_docdate1" type="date" placeholder="开始时间" value-format="yyyy-MM-dd"> </el-date-picker>
        </el-form-item>
        <el-form-item label="-" label-width="10px">
          <el-date-picker v-model="queryParam.qry_docdate2" type="date" placeholder="结束时间" value-format="yyyy-MM-dd"> </el-date-picker>
        </el-form-item>
        <el-form-item label="维修大类">
          <el-select v-model="queryParam.qry_bigtype" clearable>
            <el-option v-for="item in bigtypeList" :key="item.code" :label="item.name" :value="item.code" clearable />
          </el-select>
        </el-form-item>
        <el-form-item label="单据状态">
          <el-select v-model="queryParam.qry_state" clearable>
            <el-option v-for="item in stateList" :key="item.code" :label="item.name" :value="item.code" clearable />
          </el-select>
        </el-form-item>
      </template>
    </tl-list-search>
    <!-- 工具栏 -->
    <tl-list-toolbar ref="toolbar" @add="openAddDialog('editForm')" @exportExcel="doExportExcel" @deleteBatch="doDeleteBatch" @refresh="doRefresh" @columnCustomize="doColumnCustomize" @displaySearch="doDisplaySearch" :isDisplayDeleteBatch="selectedRowKeys.length > 0"> </tl-list-toolbar>
    <div>
      <!-- 列表选择 -->
      <div class="table-alert-div" ref="selector">
        <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
          <template slot="title">
            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
          </template>
        </el-alert>
      </div>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :height="tableHeight" resizable-key="tableHeight" :resizable-refs="['search', 'toolbar', 'selector', 'pager']" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <el-table-column type="selection" width="55px"> </el-table-column>
        <el-table-column prop="docno" label="单据编号" width="140px" sortable="custom" sort-by="docno" align="center"></el-table-column>
        <el-table-column prop="docdate" label="单据日期" width="120px" sortable="custom" sort-by="docdate" align="center">
          <template slot-scope="scope">
            {{ scope.row.docdate | toDateTime('yyyy-MM-dd') }}
          </template>
        </el-table-column>
        <el-table-column prop="usercode" label="申请人工号" width="120px" sortable="custom" sort-by="usercode" align="center"></el-table-column>
        <el-table-column prop="username" label="申请人姓名" width="120px" sortable="custom" sort-by="username" align="center"></el-table-column>
        <el-table-column prop="latestphase" label="最新阶段" width="150px" sortable="custom" sort-by="latestphase" align="center"></el-table-column>
        <el-table-column prop="dispstate" label="状态" width="100px" sortable="custom" sort-by="state" align="center"></el-table-column>
        <el-table-column prop="dispbigtype" label="维修大类" width="100px" sortable="custom" sort-by="bigtype"></el-table-column>
        <el-table-column prop="address" label="维修地址" min-width="200px" sortable="custom" sort-by="address"></el-table-column>
        <el-table-column prop="applycontent" label="维修内容" min-width="200px" sortable="custom" sort-by="applycontent"></el-table-column>
        <el-table-column prop="servicemancode" label="维修人工号" width="120px" sortable="custom" sort-by="servicemancode" align="center"></el-table-column>
        <el-table-column prop="serviceman" label="维修人" width="120px" sortable="custom" sort-by="serviceman" align="center"></el-table-column>
        <el-table-column prop="servicemanphone" label="维修人电话" width="150px" sortable="custom" sort-by="servicemanphone" align="center"></el-table-column>
        <el-table-column prop="acceptdate" label="受理时间" width="120px" sortable="custom" sort-by="acceptdate">
          <template slot-scope="scope">
            {{ scope.row.acceptdate | toDateTime('yyyy-MM-dd HH:mm:ss') }}
          </template>
        </el-table-column>
        <el-table-column prop="plandate" label="预计完成时间" width="120px" sortable="custom" sort-by="plandate">
          <template slot-scope="scope">
            {{ scope.row.plandate | toDateTime('yyyy-MM-dd HH:mm:ss') }}
          </template>
        </el-table-column>
        <el-table-column prop="completedate" label="完成时间" width="120px" sortable="custom" sort-by="completedate">
          <template slot-scope="scope">
            {{ scope.row.completedate | toDateTime('yyyy-MM-dd HH:mm:ss') }}
          </template>
        </el-table-column>
        <el-table-column prop="satisfaction" label="满意度" min-width="120px" sortable="custom" sort-by="satisfaction"></el-table-column>
        <el-table-column label="操作" width="220px" align="center" fixed="right">
          <template slot-scope="scope">
            <el-button type="text" icon="el-icon-edit" @click="openEditDialog('editForm', scope.row.id)">编辑</el-button>
            <el-button type="text" :disabled="scope.row.state !== 0" icon="el-icon-delete" @click="doDelete(scope.row.id)">删除</el-button>
            <el-button type="text" icon="el-icon-view" @click="openViewDialog('editForm', scope.row.id)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
    </div>
    <tl-edit ref="editForm" @refresh="doRefresh"></tl-edit>
  </div>
</template>

<script>
// import checkPermission from '@/utils/permission' // 权限判断函数
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './edit'
import { queryDataCode } from '@tapui/api/dataCode'
export default {
  name: 'boardroomApply',
  components: { tlEdit },
  mixins: [mixin_list],
  data() {
    return {
      description: '这是会议室申请页面',
      url: {
        list: '/toa/parkMaintenance/list',
        delete: '/toa/parkMaintenance/delete',
        deleteBatch: '/toa/parkMaintenance/deleteBatch',
        exportExcel: '/toa/parkMaintenance/exportExcel' // 导出excel
      },
      stateList: [],
      bigtypeList: [],
      sorterInfo: {
        // 排序参数
        sidx: 'docdate',
        sord: 'desc'
      }
    }
  },
  methods: {},
  created() {
    queryDataCode({ itemCodes: 'TapApprovalFlowState,ToaMaintenanceBigType' }).then(res => {
      this.stateList = res.result.TapApprovalFlowState
      this.bigtypeList = res.result.ToaMaintenanceBigType
    })
  }
}
</script>
